package cn.wzvtc.soft14;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.UUID;

/**
 * Created by linji on 2016/3/4.
 */
@RestController
@EnableAutoConfiguration
@ComponentScan
@CrossOrigin(origins = "*",
        methods = {RequestMethod.GET,RequestMethod.POST,RequestMethod.OPTIONS})
public class Test {
    String new1=null;
    public static void main(String[] args) throws Exception {
        SpringApplication.run(Test.class, args);
    }

    @Autowired
    KebiaoService kebiaoService;//new KebiaoService();

    //@RequestMapping("/getlesson")

    @RequestMapping(value="/insert")
    String insertke(int time,int endtime ,String addr,String teach,int week){
        Ke ke=new Ke();
        ke.setId(UUID.randomUUID().toString());
        ke.setTime(time);
        ke.setEndtime(endtime);
        ke.setAddr(addr);
        ke.setTeach(teach);
        ke.setWeek(week);
        kebiaoService.save(ke);
        return null;
    }
    @RequestMapping("/select")
    List select(){
        List a=kebiaoService.selete();
        return a;
    }

    @Autowired
    private UserRePo userRePo;
    @Autowired
    private UserService userService;
    @RequestMapping("/land")
    List land(String username){
        return (List)userService.select(username);
    }

    @RequestMapping("/insertuser")
    Boolean insertuser(String username,String password){
        User user=new User();
        user.setId(UUID.randomUUID().toString());
        user.setUserName(username);
        user.setPassWord(password);
        this.userRePo.save(user);
        new1="new";
        return true;
    }

    @RequestMapping("/home")
     List home() {
        return kebiaoService.getKebiao();
    }
    @RequestMapping("/new")
    String y_n(){
        String x=new1;
        new1=null;
        return x;
    }









    @RequestMapping("/duihua")
    List duihua() {
        return kebiaoService.selete2();
    }
}
